﻿namespace Chaliy.Syndication.CreativeCommons
{
    using System;
    using System.Xml;
    using System.Xml.Schema;
    using System.Xml.Serialization;
    using System.Runtime.Serialization;

    [XmlRoot("link", Namespace = Namespaces.AtomPrivate)]
    public class AtomLicenseLink : License, IXmlSerializable
    {
        #region IXmlSerializable Members

        XmlSchema IXmlSerializable.GetSchema()
        {
            throw new NotImplementedException();// TODO Implement
        }

        void IXmlSerializable.ReadXml(XmlReader reader)
        {
            throw new NotImplementedException();// TODO Implement
        }

        void IXmlSerializable.WriteXml(XmlWriter writer)
        {
            ArgumentUtilities.EnsureArgumentNotNull(writer, "writer");

            if (this.Value == null)
            {
                SerializationException valueRequiredException
                    = new SerializationException(Resources.LicenseValueRequired);

                valueRequiredException.Data["Attribute"] = "HREF";
                valueRequiredException.Data["ReasonCode"] = "RequiredAttribute";

                throw valueRequiredException;
            }

            writer.WriteAttributeString("rel", "license");
        }

        #endregion
    }
}
